<template>
  <div v-if="second[0]">
    <div class="static margin">
      <img :src="second[0].bannerImgSrc" alt="">
    </div>
    <div class="special margin">
      <img :src="second[1].bannerImgSrc" alt="">
    </div>
    <div class="chairs margin">
      <div class="single-chair" v-for="item in second[2].banners" :key="item.id" @click="handleGroup(item.bannerLinkTargetId)">
        <img :src="item.bannerImgSrc" alt="">
      </div>
    </div>
    <div class="chairs margin">
      <div class="single-chair" v-for="item in second[3].banners" :key="item.id" @click="handleGroup(item.bannerLinkTargetId)">
        <img :src="item.bannerImgSrc" alt="">
      </div>
    </div>
    <div class="sofa margin">
      <div class="single-sofa" :key="item.id" v-for="item in second[4].banners">
        <img :src="item.bannerImgSrc" alt="">
      </div>
    </div>
    <div class="sofa margin">
      <div class="single-sofa" :key="item.id" v-for="item in second[5].banners">
        <img :src="item.bannerImgSrc" alt="">
      </div>
    </div>
    <div class="sofa margin">
      <div class="single-sofa" :key="item.id" v-for="item in second[6].banners">
        <img :src="item.bannerImgSrc" alt="">
      </div>
    </div>
    <div class="margin">
      <img :src="second[7].bannerImgSrc" alt="">
    </div>
    <threedata></threedata>
  </div>
</template>

<script>
import axios from 'axios'
import threedata from './three'
export default {
  data () {
    return {
      second: []
    }
  },
  mounted () {
    window.onscroll = () => {
      if ((document.documentElement.scrollTop + document.documentElement.clientHeight) === document.documentElement.scrollHeight) {
        axios.get('/v2/page?pageId=1&tabId=1&currentPage=2&pageSize=8&_=1583387875383').then(res => {
          this.second = res.data.data.modules.map(item => item.moduleContent)
        })
      }
    }
  },
  methods: {
    handleGroup (targetId) {
      this.$router.push(`/productGroup/${targetId}`)
    }
  },
  destroyed () {
    window.onscroll = null
  },
  components: {
    threedata
  }
}
</script>

<style lang="scss" scoped>
img{
  width: 100%;
}
.craftsman {
  width: 100%;
  background: white;
  padding: 40px 15px 15px 15px;
  box-sizing: border-box;
  .products{
    display: flex;
    justify-content: space-between;
    .single-goods{
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 30%;
      font-size: 14px;
      span{
        width: 100%;
        overflow:hidden;
        white-space:nowrap;
        text-overflow:ellipsis;
        text-align: center;
      }
    }
  }
}
.chairs{
  display: flex;
  padding:50px 15px 10px 15px;
  background: white;
  justify-content: space-between;
  .single-chair{
    width: 30%;
  }
}
.sofa{
  display: flex;
  background: white;
  padding: 30px 15px 10px 15px;
  justify-content: space-between;
  .single-sofa{
    width: 48%;
  }
}
</style>
